package top.chmin.project.cloud.sys.column.info;
import top.chmin.project.cloud.common.*;
import java.util.List;
import java.util.stream.Stream;


/**
 * chmin
 * 2024-01-25 14:22:04
 * cloud-code
 */
public class ColumnInfoCondition extends Condition {
    private ColumnInfoCondition parent = null;

    ColumnInfoCondition() {
    }

    private ColumnInfoCondition(ColumnInfoCondition condition) {
        this.parent = condition;
    }

    public static ColumnInfoCondition forDelete() {
        ColumnInfoCondition condition = new ColumnInfoCondition();
        condition.setSql("DELETE FROM sys_column_info#where##group##order##limit#");
        return condition;
    }

    public static ColumnInfoCondition forSelect() {
        ColumnInfoCondition condition = new ColumnInfoCondition();
        condition.modelClass = ColumnInfo.class;
        condition.setSql("SELECT #select# FROM sys_column_info#where##group##order##limit#");
        return condition;
    }

    public ColumnInfoCondition distinct() {
        this.distinct = true;
        return this;
    }

    public ColumnInfoCondition limit(int limit) {
        this.limit = " LIMIT " + limit;
        return this;
    }

    public ColumnInfoCondition sub() {
        return new ColumnInfoCondition(this);
    }

    public ColumnInfoCondition finish() {
        if (!whereList.isEmpty()) {
            parent.whereList.add("(" + String.join(" OR ", whereList) + ")");
        }
        parent.whereValueList.addAll(whereValueList);
        return parent;
    }

    public ColumnInfo selectFirst() {
        return selectFirst(ColumnInfo.class);
    }

    public List<ColumnInfo> selectList() {
        return selectList(ColumnInfo.class);
    }

    public Stream<ColumnInfo> selectStream() {
        return selectStream(ColumnInfo.class);
    }

    public Page<ColumnInfo> selectPage() {
        return selectPage(ColumnInfo.class);
    }

    /*###########auto#start###########*/
    public static int deleteByColumnCode(String columnCode) {
        return forDelete().columnCode().eq(columnCode).execute();
    }

    public static ColumnInfo selectByColumnCode(String columnCode) {
        return forSelect().columnCode().eq(columnCode).selectFirst(ColumnInfo.class);
    }

    public static <T> T selectByColumnCode(String columnCode, Class<T> clazz) {
        return forSelect().columnCode().eq(columnCode).selectFirst(clazz);
    }

    public static int deleteByColumnNameAndTableCode(String columnName, String tableCode) {
        return forDelete().columnName().eq(columnName).tableCode().eq(tableCode).execute();
    }

    public static ColumnInfo selectByColumnNameAndTableCode(String columnName, String tableCode) {
        return forSelect().columnName().eq(columnName).tableCode().eq(tableCode).selectFirst(ColumnInfo.class);
    }

    public static <T> T selectByColumnNameAndTableCode(String columnName, String tableCode, Class<T> clazz) {
        return forSelect().columnName().eq(columnName).tableCode().eq(tableCode).selectFirst(clazz);
    }

    /*###########auto##end############*/
    /* append $conditionIndexAppender$ */
    /*###########auto#start###########*/
    public ColumnCode columnCode() {
        return new ColumnCode();
    }

    public class ColumnCode extends StringFlexColumn<ColumnInfoCondition> {
        private ColumnCode() {
            super(ColumnInfoCondition.this, "column_code");
        }
    }

    public ColumnComment columnComment() {
        return new ColumnComment();
    }

    public class ColumnComment extends StringFlexColumn<ColumnInfoCondition> {
        private ColumnComment() {
            super(ColumnInfoCondition.this, "column_comment");
        }
    }

    public ColumnDict columnDict() {
        return new ColumnDict();
    }

    public class ColumnDict extends StringFlexColumn<ColumnInfoCondition> {
        private ColumnDict() {
            super(ColumnInfoCondition.this, "column_dict");
        }
    }

    public ColumnLabel columnLabel() {
        return new ColumnLabel();
    }

    public class ColumnLabel extends StringFlexColumn<ColumnInfoCondition> {
        private ColumnLabel() {
            super(ColumnInfoCondition.this, "column_label");
        }
    }

    public ColumnLength columnLength() {
        return new ColumnLength();
    }

    public class ColumnLength extends IntegerFlexColumn<ColumnInfoCondition> {
        private ColumnLength() {
            super(ColumnInfoCondition.this, "column_length");
        }
    }

    public ColumnName columnName() {
        return new ColumnName();
    }

    public class ColumnName extends StringFlexColumn<ColumnInfoCondition> {
        private ColumnName() {
            super(ColumnInfoCondition.this, "column_name");
        }
    }

    public ColumnNullable columnNullable() {
        return new ColumnNullable();
    }

    public class ColumnNullable extends StringFlexColumn<ColumnInfoCondition> {
        private ColumnNullable() {
            super(ColumnInfoCondition.this, "column_nullable");
        }
    }

    public ColumnPrecision columnPrecision() {
        return new ColumnPrecision();
    }

    public class ColumnPrecision extends IntegerFlexColumn<ColumnInfoCondition> {
        private ColumnPrecision() {
            super(ColumnInfoCondition.this, "column_precision");
        }
    }

    public ColumnRelate columnRelate() {
        return new ColumnRelate();
    }

    public class ColumnRelate extends StringFlexColumn<ColumnInfoCondition> {
        private ColumnRelate() {
            super(ColumnInfoCondition.this, "column_relate");
        }
    }

    public ColumnScale columnScale() {
        return new ColumnScale();
    }

    public class ColumnScale extends IntegerFlexColumn<ColumnInfoCondition> {
        private ColumnScale() {
            super(ColumnInfoCondition.this, "column_scale");
        }
    }

    public ColumnSequence columnSequence() {
        return new ColumnSequence();
    }

    public class ColumnSequence extends StringFlexColumn<ColumnInfoCondition> {
        private ColumnSequence() {
            super(ColumnInfoCondition.this, "column_sequence");
        }
    }

    public ColumnType columnType() {
        return new ColumnType();
    }

    public class ColumnType extends StringFlexColumn<ColumnInfoCondition> {
        private ColumnType() {
            super(ColumnInfoCondition.this, "column_type");
        }
    }

    public CreateBy createBy() {
        return new CreateBy();
    }

    public class CreateBy extends StringFlexColumn<ColumnInfoCondition> {
        private CreateBy() {
            super(ColumnInfoCondition.this, "create_by");
        }
    }

    public CreateTime createTime() {
        return new CreateTime();
    }

    public class CreateTime extends LocalDateTimeFlexColumn<ColumnInfoCondition> {
        private CreateTime() {
            super(ColumnInfoCondition.this, "create_time");
        }
    }

    public Id id() {
        return new Id();
    }

    public class Id extends IntegerFlexColumn<ColumnInfoCondition> {
        private Id() {
            super(ColumnInfoCondition.this, "id");
        }
    }

    public TableCode tableCode() {
        return new TableCode();
    }

    public class TableCode extends StringFlexColumn<ColumnInfoCondition> {
        private TableCode() {
            super(ColumnInfoCondition.this, "table_code");
        }
    }

    public UpdateBy updateBy() {
        return new UpdateBy();
    }

    public class UpdateBy extends StringFlexColumn<ColumnInfoCondition> {
        private UpdateBy() {
            super(ColumnInfoCondition.this, "update_by");
        }
    }

    public UpdateTime updateTime() {
        return new UpdateTime();
    }

    public class UpdateTime extends LocalDateTimeFlexColumn<ColumnInfoCondition> {
        private UpdateTime() {
            super(ColumnInfoCondition.this, "update_time");
        }
    }

    /*###########auto##end############*/
    /* append $conditionFieldAppender$ */
}
